package com.example.demo.model;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class Role extends BaseEntity {
    private Integer roleId;
    private String roleName;
    private String description;
    
    /**
     * 角色等级（用于判断权限高低）
     */
    public static int getPrivilegeLevel(String roleName) {
        switch (roleName) {
            case "SUPER_ADMIN": return 6;
            case "SCHOOL_ADMIN": return 5;
            case "DEPARTMENT_ADMIN": return 4;
            case "MAJOR_ADMIN": return 3;
            case "CLASS_ADMIN": return 2;
            case "TEACHER": return 1;
            case "STUDENT": return 0;
            default: return -1;
        }
    }
    
    /**
     * 获取当前角色的权限级别
     */
    public int getPrivilegeLevel() {
        return getPrivilegeLevel(this.roleName);
    }
    
    /**
     * 判断当前角色是否有权限审批目标角色
     * @param targetRole 目标角色
     * @return 是否有权限审批
     */
    public boolean canApprove(String targetRole) {
        return getPrivilegeLevel(this.roleName) > getPrivilegeLevel(targetRole);
    }
} 